// 合并两个有序数组

package Leetcode;

class solution_088 {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int[] nums3 = new int[m];
        for (int i = 0; i < m; i++) {
            nums3[i] = nums1[i];
        }
        int length1 = 0;
        int length2 = 0;
        int length3 = 0;
        while (length3 != m && length2 != n) {
            if (nums3[length3] <= nums2[length2])
                nums1[length1++] = nums3[length3++];
            else
                nums1[length1++] = nums2[length2++];
        }
        if (length3 < m) {
            for (int i = length3; i < m; i++)
                nums1[length1++] = nums3[i];
        }
        if (length2 < n) {
            for (int i = length2; i < n; i++)
                nums1[length1++] = nums2[i];
        }
    }
}

public class Solution088 {

}
